package GUI;

import use.VIPuse;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.util.List;

public class revise {
    private JPanel panel1;
    private JComboBox comboBox1;
    private JTextField textField1;
    private JButton 会员卡充值Button;
    private JButton 新会员注册Button;
    private JButton 查询修改会员信息Button;
    private JButton 更改系统密码Button;
    private JButton 查询消费记录Button;
    private JButton 会员卡汇总记录Button;
    private JTextField 修改状态为禁用则填写TextField;
    private JButton 使用会员卡Button;
    private JButton 修改电话Button;
    private JButton 修改姓名Button;
    private JButton 修改状态Button;
    private JTextField newnum;
    private JTextField newname;
    private JButton 消费记录报表Button;
    private JTable table1;
    public static void iface()
    {
        JFrame frame = new JFrame("游泳馆会员管理系统");
        frame.setSize(500, 400);
        frame.setLocation(400, 200);

        revise t1 = new revise();
        frame.add(t1.panel1);

        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
    public revise()
    {
        会员卡充值Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new recharge().iface();
            }
        });
        查询消费记录Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new consume().iface();
            }
        });
        查询修改会员信息Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new revise().iface();
            }
        });
        更改系统密码Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new password().iface();
            }
        });
        新会员注册Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new VIP().iface();
            }
        });
        会员卡汇总记录Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new totalVIP().iface();
            }
        });
        使用会员卡Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new usecard().iface();
            }
        });
        修改电话Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                VIPuse vip=new VIPuse();
                String[] a=new String[2];
                a[0]=newnum.getText();
                a[1]=textField1.getText();
                List<?> state;
                state=vip.修改电话(a);
                if(state == null)
                {
                    JOptionPane.showMessageDialog(null, "非营业时间", "提示",
                            JOptionPane.INFORMATION_MESSAGE);
                }
               else {
                    JOptionPane.showMessageDialog(null, "修改成功", "提示",
                            JOptionPane.INFORMATION_MESSAGE);
                }
            }
        });
        修改姓名Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                VIPuse vip=new VIPuse();
                String[] a=new String[2];
                a[0]=newname.getText();
                a[1]=textField1.getText();
                List<?> state;
                state=vip.修改姓名(a);;
                if(state == null)
                {
                    JOptionPane.showMessageDialog(null, "非营业时间", "提示",
                            JOptionPane.INFORMATION_MESSAGE);
                }
                else {
                    JOptionPane.showMessageDialog(null, "修改成功", "提示",
                            JOptionPane.INFORMATION_MESSAGE);
                }
            }
        });
        修改状态Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                VIPuse vip=new VIPuse();
                String statement;
                String[] a=new String[3];
                String[] b=new String[2];
                String cardnum;
                cardnum=textField1.getText();
                statement=comboBox1.getSelectedItem().toString();
                a[0]=statement;
                a[1]=修改状态为禁用则填写TextField.getText();
                a[2]=textField1.getText();
                List<?> state;
                if(statement.equals("退卡"))
                {
                    state=vip.删除(cardnum);
                    if(state == null)
                    {
                        JOptionPane.showMessageDialog(null, "非营业时间", "提示",
                                JOptionPane.INFORMATION_MESSAGE);
                    }
                    else {
                        JOptionPane.showMessageDialog(null, "退卡成功", "提示",
                                JOptionPane.INFORMATION_MESSAGE);
                    }
                }
                else if(statement.equals("禁用"))
                {
                    state=vip.修改为禁用状态(a);
                    if(state == null)
                    {
                        JOptionPane.showMessageDialog(null, "非营业时间", "提示",
                                JOptionPane.INFORMATION_MESSAGE);
                    }
                    else {
                        JOptionPane.showMessageDialog(null, "修改成功", "提示",
                                JOptionPane.INFORMATION_MESSAGE);
                    }

                }
                else if(statement.equals("正常"))
                {
                    b[0]=statement;
                    b[1]=textField1.getText();
                    state=vip.修改为正常状态(b);
                    if(state == null)
                    {
                        JOptionPane.showMessageDialog(null, "非营业时间", "提示",
                                JOptionPane.INFORMATION_MESSAGE);
                    }
                    else {
                        JOptionPane.showMessageDialog(null, "修改成功", "提示",
                                JOptionPane.INFORMATION_MESSAGE);
                    }
                }

            }
        });
        消费记录报表Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new baobiao().iface();
            }
        });
    }

    public static void main(String[] args) {
       iface();
    }

}
